<!--
公文查询->筛选
-->
<template>
	<view>
		<van-search
		  v-model="title"
		  show-action
		  placeholder="请输入搜索关键词"
		  @input="onSearch"
		>
		  <template #action>
		    <van-dropdown-menu active-color="#1989fa">
		    	<van-dropdown-item title="筛选" ref="item">
		    		<docFilter @filterToggle="filterToggle" :title="title"></docFilter>
		    	</van-dropdown-item>
		    </van-dropdown-menu>
		  </template>
		</van-search>
		<resultList ref="resultList" :queryData="queryData"/>
	</view>
</template>

<script>
	import resultList from 'pages/admin/components/query/compo-resultList';
	import docFilter from 'pages/admin/components/query/compo-queryFilter';
	export default {
		components: {
			resultList,
			docFilter
		},
		data() {
			return {
        title:'',
        queryData:{
          title: '',//标题
          bizTypeCode: '',//公文类型code
          bizTypeName:'全部',//公文类型名称
          cbr: '',//呈报人code
          cbrName:'',//呈报人name
          cbdept: '',//呈报单位code
          cbdeptName: '',//呈报单位name
          personalClassification:'sygw',//个性分类code
          personalClassificationName:'',//个性分类name
          taskNumber:'',//外事任务编号
          date: '',
          createTimeStart:'',
          createTimeEnd:'',
          orderName:'completeTime',//排序completeTime结束时间,createTime提交时间,code公文类型,cbdept单位
          orderNameName:'结束时间'
        },
        timeout:null,
			};
		},
		methods: {
      onSearch(){
        clearTimeout(this.timeout);
        this.timeout = setTimeout(() => {
          this.queryData.title = this.title
        },300)

      },
			onSelectDocType(item) {
				this.docType = item.name
				this.showDocType = false
			},
			formatDate(date) {
				return `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`;
			},
			onConfirmDate(date) {
				const [start, end] = date;
				this.showdateRange = false;
				this.date = `${this.formatDate(start)} - ${this.formatDate(end)}`;
			},
      //子组件向父组件传值调用
			filterToggle(data) {
        Object.keys(data).forEach((key)=>{
          this.queryData[key] = data[key]
        })
        if(this.util.isEmpty(this.queryData.title)){
          this.title=''
        }
        // this.queryData.bizTypeCode = data.bizTypeCode
        this.queryData.title = this.title
        // console.log('查询参数',JSON.stringify(queryData))
				this.$refs.item.toggle();
			}
		},
	};
</script>

<style scoped>
	/deep/ .van-search__content {
		padding-left: 0;
	}
	/deep/ .van-cell {
		padding: 16rpx 30rpx;
	}
	/deep/ .van-dropdown-menu__bar {
    box-shadow: none;
	}
  /deep/ .van-dropdown-menu__bar--opened {
    z-index: 10;
  }
  /deep/ .van-search__action {
    margin: 0 8px;
    padding: 0 0px;
  }
</style>
